<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<%@ include file="../header.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Insert title here</title>
	<style type="text/css">
		.main_div{
			margin : 15px;
		}
	</style>
</head>
<body>
<div class="main_div">
	<form id="form_insert" class="layui-form layui-form-pane" action="">
		<div class="layui-form-item">
			<label class="layui-form-label">机会来源</label>
			<div class="layui-input-block">
				<input type="text" name="chanceSource" autocomplete="off" placeholder="请输入标题" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">所属客户</label>
			<div class="layui-input-block">
				<select name="customerId">
					<option value="">--选择客户--</option>
					<c:forEach items="${customerList}" var="customer">
						<option value="${customer.id}">${customer.name}</option>
					</c:forEach>
				</select>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">意向产品</label>
			<div class="layui-input-block">
				<select name="productId">
					<option value="">--选择产品--</option>
					<c:forEach items="${productList}" var="product">
						<option value="${product.id}">${product.name}</option>
					</c:forEach>
				</select>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">指派营销人员</label>
			<div class="layui-input-block">
				<select name="userId">
					<option value="">--选择营销人员--</option>
					<c:forEach items="${userList}" var="user">
						<option value="${user.id}">${user.name}</option>
					</c:forEach>
				</select>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">成功几率</label>
			<div class="layui-input-inline">
				<input type="text" name="successRate" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">机会描述</label>
			<div class="layui-input-inline">
				<input type="text" name="description" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">创建人</label>
			<div class="layui-input-inline">
				<input type="text" value="${user_in_session.name}" name="createMan" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
			</div>
		</div>
	</form>
	<button class="layui-btn" onclick="submitForm()">保存</button>
</div>


<script>
	layui.use(['form'], function(){
		var form = layui.form;

	});

	//ajax方式提交form表单
	function submitForm(){
		$.ajax({
			url : '${path}/saleChance/update',
			data : $('#form_add').serialize(),
			type : 'POST',
			dataType : 'json',
			success : function(jsonResult) {
				if(jsonResult.ok) {
					//mylayer.success(jsonResult.msg);
					mylayer.confirm("保存成功，是否跳转到员工管理界面？", "${path}/saleChance/getSaleChancePage");
				} else {
					mylayer.errorMsg(jsonResult.msg);
				}
			}
		});
	}

</script>
</body>
</html>